import request from '@/utils/axios';

import { UserListVO, UserVO } from './types';

export const listApi = (data: any) => {
  return request.post<UserListVO>({ url: '/system/user/list', data });
};

export const listSimpleApi = (data: any) => {
  return request.post<UserListVO>({ url: '/system/user/listSimple', data });
};

export const searchApi = (realName: string) => {
  return request.post<UserVO[]>({
    url: '/system/user/search',
    params: { realName },
  });
};

export const getApi = (id: string) => {
  return request.get<UserVO>({ url: '/system/user/get/' + id });
};

export const saveApi = (data: any) => {
  return request.post({ url: '/system/user/save', data });
};

export const updateApi = (data: any) => {
  return request.post({ url: '/system/user/update', data });
};

export const updatePwApi = (id: string, password: string) => {
  return request.post({
    url: '/system/user/updatePassword',
    data: { id, password },
  });
};

export const removeApi = (id: string) => {
  return request.post({ url: '/system/user/remove', params: { id } });
};
